<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <title>e网批发管理后台</title>
  <?php 
  include("common/conn.php"); 
  include("./tool/UpFileTool.class.php");
  if($_SESSION['userid']==""){echo "<script>window.location.href='login.php';</script>";} 

  if($_GET['action']=="ok")
  { 
  // if ($_FILES) {
  //   $UpFileTool=new UpFileTool('upfile1');
  //   $UpFileTool->sumbImage($w=500, $h=500);
  //   $UpFileTool->upFile();
  //   $images = $UpFileTool->sumbImage;
  //   $srcimages = $UpFileTool->srcImage;
  // }

$date=date("Y-m-d h:i:s");
$srat=mysql_query("INSERT INTO categroy(name,categroy_type_id) VALUES ('$_POST[name]','$_POST[categroy_type_id]')");
// $srat=mysql_query("INSERT INTO categroy(name,images,srcimages,categroy_type_id) VALUES ('$_POST[name]','$images','$srcimages','$_POST[categroy_type_id]')");
echo "<script>window.location.href='fenlei.php';</script>";
}

if($_GET['id']!=""){
  $rert30=mysql_query("select * from categroy where cateid='".$_GET['id']."'");
  $sdg30=mysql_fetch_array($rert30);
}


//分类的类型
$rert33 = mysql_query("select * from categroy_type");

if($_GET['ch']=="ok")
{    
  // if ($_FILES[upfile1][name]) {
  //   $UpFileTool=new UpFileTool('upfile1');
  //   $UpFileTool->sumbImage($w=500, $h=500);
  //   $UpFileTool->upFile();
  //   $images = $UpFileTool->sumbImage;
  //   $srcimages = $UpFileTool->srcImage;
  //   $srat1=mysql_query("update categroy set images='".$images."',srcimages='".$srcimages."' where cateid='".$_REQUEST['id']."'");
  // }
$srat1=mysql_query("update categroy set name='".$_POST['name']."' where cateid='".$_REQUEST['id']."'");
$srat1=mysql_query("update categroy set categroy_type_id='".$_POST['categroy_type_id']."' where cateid='".$_REQUEST['id']."'");

echo "<script>window.location.href='fenlei.php';</script>";
}


?>
<script type="text/javascript" src="js/jquery.min.js"></script>

<!-- MASTER STYLESHEET-->
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<script src="js/graphs.js" type="text/javascript"></script>


</head>

<body>

  <!--header-->
  <?php include("common/header.php");?>
  <!--header end-->


  <!-- staqrt subnav -->
  <div id="sub_nav">

    <div id="subnav_wrap" class="container_12">
      <div id="subnav" class=" grid_12">

        <ul>
          <li> <a href="fenlei.php" class="sub_nav_active"> 分类管理 </a></li>
          <li><a href="fenlei_leixing.php">分类类型管理</a></li>
        </ul>

      </div>

    </div>


  </div>

  <div class="container_12">
    <form action="?<?php if($_GET['id']!=""){echo "ch=ok";}else{echo "action=ok";} ?>" method="post"  enctype="multipart/form-data" >
      <h2>添加分类</h2>  	
      <table width="100%" border="0" cellpadding="0" cellspacing="0">



        <tr>


<!--           <tr>
            <th width="20%" scope="col">分类图片</th>
            <th width="80%" scope="col"><input name="upfile1" type="file" /><?php if($_GET[id]!=""){?><img src="<?php echo $sdg30[images];?>" width="100" height="100"/><?php }?></th>
          </tr> -->

          <tr>
            <th width="20%" scope="col">分类名称</th>
            <th width="80%" scope="col"><input name="name" type="text"  value="<?php echo $sdg30[name];?>"/></th>
          </tr>

          <tr>
            <th width="20%" scope="col">分类类型</th>
            <th width="80%" scope="col">
              <select name="categroy_type_id">             
                <?php  while($sdg33=mysql_fetch_array($rert33)){?>
                <option <?php if($sdg30[categroy_type_id]==$sdg33[id]){echo "selected='selected'";}?>  value="<?php echo $sdg33[id];?>"><?php echo $sdg33[type];?></option>
                <?php }?>                      
              </select>

            </th>
          </tr>

          <tr>
            <th width="20%" scope="col"></th>
            <th width="80%" scope="col"><input name="id" type="hidden" value="<?php echo $_GET[id];?>" /><input name="" type="submit" value="提交" /></th>
          </tr>

        </tr>


      </table>
    </form>          
  </div>
</form>
</body>
</html>
